/**
 * 
 */
package com.jcode.skeleton.config;

import java.util.concurrent.ConcurrentHashMap;

import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.apache.commons.configuration2.ex.ConfigurationException;

/**
 *
 * @Author dreajay
 * @DateTime 2017年4月15日 上午10:11:00
 * 
 */
public class SystemConfiguration {

	private static volatile Configuration configuration;

	private static final ConcurrentHashMap<String, Configuration> cachePool = new ConcurrentHashMap<String, Configuration>(10);

	public static Configuration getDefault() {
		return configuration;
	}

	public static Configuration getConfiguration(String path) {
		return cachePool.get(path);
	}

	public static Configuration createConfiguration(String path) throws ConfigurationException {
		Configurations configs = new Configurations();
		PropertiesConfiguration config = configs.properties(path);
		cachePool.put(path, config);
		return config;
	}

}
